package com.example.jinmingwu.a180531_service;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.widget.Toast;

/**
 * Created by jinmingwu on 2018/5/31.
 */

public class music extends Service {
    private MediaPlayer player=null;

    public IBinder onBind(Intent intent) {
        return null;
    }

    public void onStart(Intent intent,int startId){
        super.onStart(intent,startId);
        Toast.makeText(this, "开始播放音乐", Toast.LENGTH_SHORT).show();
        final MediaPlayer player=MediaPlayer.create(this,R.raw.song);
        player.start();

    }

    public void onDestroy(){
        onDestroy();
        if(player!=null) {
            player.stop();
            player.release();
        }
    }
}
